home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / news / readers / skim-0.8 / skim-0 / skim-0.8.4 / skim < prev    next >
Text File  |  1996-02-18  |  22KB  |  680 lines

  1. #!/bin/bash
  2.  
  3. # NAME
  4. #    skim
  5. # USAGE
  6. #    skim subjects
  7. #    skim articles
  8. #    skim cleanup
  9. #    skim newarticle [FileName NewsGroups Subject]
  10. #    skim replyto ArticleFile ...
  11. #    skim post ArticleFile
  12. #    skim postall
  13. #    skim newsgroups
  14. #    skim delete ArticleFile
  15. #    skim keep ArticleFile
  16. #    skim indexes
  17. #    skim version
  18. #    skim listsubscribednewsgroups
  19. # NOTE
  20. #    The description below is reference information. Refer to the accompanying
  21. #    README for an introduction.
  22. # DESCRIPTION
  23. #
  24. #    skim subjects:
  25. #        Retrieve the subject header lines of all new articles in the
  26. #        subscribed groups. The subject header lines are appended to the files
  27. #        If SKIMAUTOSUBJECT is set, automatically select and kill subjects.
  28. #        if SKIMAUTOAUTHOR is set, automatically select and kill authors.
  29. #
  30. #    skim articles:
  31. #        Retrieve the articles which were selected in the files
  32. #        $SKIMDIR/Subjects. The articles are stored in $SKIMDIR/Articles.
  33. #        The subject lines of the articles which were not selected are
  34. #        appended to the files in $SKIMDIR/Skipped. The files in
  35. #        $SKIMDIR/Subjects are removed.
  36. #
  37. #    skim delete ArticleFile
  38. #        Delete an article from the directory $SKIMDIR/Articles by moving it
  39. #        to the directory $SKIMDIR/Deleted. The article will no longer show up
  40. #        in xskim. The article is physically removed when you execute the
  41. #        command 'skim cleanup'.
  42. #
  43. #        When you bypass the command 'skim delete ArticleFile' and use the 'rm'
  44. #        command to remove it, you will find that xskim still shows the article
  45. #        in it's article list. Xskim raises an error when you select an article
  46. #        that was removed this way.
  47. #
  48. #    skim keep ArticleFile
  49. #        Delete an article from the directory $SKIMDIR/Articles by moving it
  50. #        to the directory $SKIMDIR/Kept. The article will no longer show up
  51. #        in xskim. Skim never removes articles from $SKIMDIR/Kept.
  52. #
  53. #        When you bypass the command 'skim keep ArticleFile' and use the 'mv'
  54. #        command move it to another location, you will find that xskim still 
  55. #        shows the article in it's article list. Xskim raises an error when you
  56. #        select an article that was moved this way.
  57. #
  58. #    skim cleanup:
  59. #        Remove the files in $SKIMDIR/Skipped, $SKIMDIR/Killed and 
  60. #        $SKIMDIR/Deleted. Use this command regularly to cleanup skim's 
  61. #        accumulating administrative information. The NNTP server is not 
  62. #        contacted.
  63. #
  64. #    skim replyto ArticleFile ...
  65. #        Skim constructs a RFC-1036 compliant reply to one or more USENET news 
  66. #        messages in $SKIMDIR/Articles, and puts the replies in $SKIMDIR/Post.
  67. #        The filename of a reply is <ArticleFile>.reply.
  68. #        Skim uses the following information to construct the reply:
  69. #
  70. #            - Various header lines of the original article.
  71. #            - The environment variable SKIMFROM.
  72. #            - The environment variable SKIMFREPLYTO (optional).
  73. #            - The body of the original article.
  74. #            - Your ~/.signature, if it exists.
  75. #
  76. #    skim newarticle [FileName NewsGroups Subject]
  77. #       Skim constructs a RFC-1036 compliant news article and puts it in 
  78. #       $SKIMDIR/Post. When you don't specify the local filename, newsgroups 
  79. #       and subject on the command line, Skim will prompt you for it. Skim 
  80. #       also uses the following information:
  81. #
  82. #            - The environment variable SKIMFROM.
  83. #            - The environment variable SKIMREPLYTO (optional).
  84. #            - Your ~/.signature, if it exists.
  85. #
  86. #    skim post ArticleFile
  87. #       Skim posts the ArticleFile (which must reside in $SKIMDIR/Post) to the 
  88. #       newsgroups specified in the 'Newsgroups:' line in the article. Use 
  89. #       'skim newarticle' or 'skim replyto' to create an article.
  90. #
  91. #    skim postall
  92. #       Skim posts all articles in $SKIMDIR/Post. Use with caution. When
  93. #       there is garbage in $SKIMDIR/Post, you may be violating RFC-977 or
  94. #       RFC-1036.
  95. #
  96. #    skim newsgroups
  97. #       Retrieve the list of valid newsgroups from the server, and store it in
  98. #       $SKIMDIR/Admin/AllNewsGroups.
  99. #
  100. #    skim indexes
  101. #       Regenerate all the index files maintained by skim. You do not normally
  102. #       need to use this command. Should skim's index files ever get 
  103. #       out of date (for example, when you use the file manager or the 'rm'
  104. #       command to remove an article file, instead of using 'skim delete'),
  105. #       you can use the command 'skim indexes' to regenerate the index files.
  106. #
  107. #    skim version
  108. #       Print the version of skim on the standard output.
  109. #
  110. #    skim listsubscribednewsgroups
  111. #       Print the list of newsgroups the user is subscribed to on stdout.
  112. #       One newsgroup per line.
  113. # ENVIRONMENT
  114. #    NNTPSERVER        : Hostname of the NNTP news server.
  115. #    SKIMDIR           : Location of skim's per user directory structure. Defaults 
  116. #                        to ~/Skim.
  117. #    TMPDIR            : Directory to use for temporary files. Defaults to /tmp.
  118. #    SKIMFROM          : Used to construct the 'From:' line of your news 
  119. #                        messages. See RFC-822 for the semantics of the 'From:'
  120. #                        line. Use one of the following patterns:
  121. #
  122. #                           "R.W.Pijlman@inter.NL.net"
  123. #                           "R.W.Pijlman@inter.NL.net (Rene Pijlman)"
  124. #                           "Rene Pijlman <R.W.Pijlman@inter.NL.net>"
  125. #
  126. #    SKIMPATH          : This variable may optionally be defined, and is used
  127. #                        to construct the 'Path:' header line. See RFC-1036 
  128. #                        for the semantics of the Path line.
  129. #    SKIMREPLYTO       : This variable may optionally be defined, and causes a
  130. #                        'Reply-To:' line to be included in your news messages.
  131. #                        Use the same pattern as for SKIMFROM. See RFC-822 for
  132. #                        the semantics of the Reply-To line.
  133. #    SKIMORGANIZATION  : This variable may optionally be defined, and causes a
  134. #                        'Organization:' line to be included in your news
  135. #                        messages. See RFC-1036 for the semantics of the
  136. #                        Organization line.
  137. #    SKIMPROCESSES     : The maximum number of concurrent processes that talk 
  138. #                        to the NNTP server. The default is 4. Set this
  139. #                        to a higher number if you think this will improve
  140. #                        the utilization of your dialup line. Set this to a
  141. #                        lower number (e.g. 1) when either your machine or
  142. #                        the news server is overloaded, or when your news
  143. #                        server limits the maximum number of concurrent
  144. #                        connections per client IP address.
  145. #    SKIMAUTOSUBJECT     When this is set to "CaseSensitive" or 
  146. #                        "CaseInsensitive", skim will automatically select and 
  147. #                        kill subjects.
  148. #    SKIMAUTOAUTHOR      When this is set to "CaseSensitive" or 
  149. #                        "CaseInsensitive", skim will automatically select and 
  150. #                        kill authors.
  151. #    SKIMLENGTHAUTHOR    The length of the Author column in the Subjects file.
  152. #                        The default is 20. Make sure there are no files in
  153. #                        $SKIMDIR/Subjects when you change the length.
  154. # FILES
  155. #    $SKIMDIR/Admin/SubscribedNewsGroups
  156. #        The list of news groups (one per line) to which the user is subscribed.
  157. #        When this file does not exist, skim will create a default. Lines
  158. #        with '#' on the first position are ignored.
  159. #    $SKIMDIR/Subjects/
  160. #        A directory with one file per news group. Skim will create this file
  161. #        when 'skim subjects' is performed. The file contains all the subject 
  162. #        header lines acummulated since the last 'skim articles' command. The
  163. #        user must edit the subject files and select articles by shifting
  164. #        lines to the right (>> in vi).
  165. #    $SKIMDIR/Articles
  166. #        A directory with one file per retrieved article. The pattern for file 
  167. #        names is Group.ArticleNumber. Articles are added here when 'skim 
  168. #        articles' is performed. Articles in this directory show up in xskim. 
  169. #        When you've read an article you can either delete it using 'skim 
  170. #        delete' or keep it using 'skim keep'. Only these two skim commands 
  171. #        remove articles from the directory $SKIMDIR/Articles.
  172. #    $SKIMDIR/Deleted
  173. #        Articles are moved to this directory when you execute the command
  174. #        'skim delete ArticleFile'. Articles are removed from this directory
  175. #        when you execute the command 'skim cleanup'.
  176. #    $SKIMDIR/Kept
  177. #        Articles are moved to this directory when you execute the command
  178. #        'skim keep ArticleFile'. Skim never removes articles from this
  179. #        directory.
  180. #    $SKIMDIR/Skipped
  181. #        A directory with one file per news group. This is just a safety copy
  182. #        of the subject lines which were not selected when 'skim articles'
  183. #        was performed. Use 'skim cleanup' regularly to remove these files.
  184. #    $SKIMDIR/Patterns/Subject/AutoSelect
  185. #        A directory with one file per newsgroup, and optionally m4 include 
  186. #        files. The files contain regular expressions which are used to 
  187. #        automatically select subjects when 'skim subjects' is performed.
  188. #    $SKIMDIR/Patterns/Subject/Kill
  189. #        A directory with one file per newsgroup, and optionally m4 include 
  190. #        files. The files contain regular expressions which are used to 
  191. #        automatically kill subjects when 'skim subjects' is performed.
  192. #    $SKIMDIR/Patterns/Author/AutoSelect
  193. #        A directory with one file per newsgroup, and optionally m4 include 
  194. #        files. The files contain regular expressions which are used to 
  195. #        automatically select authors when 'skim subjects' is performed.
  196. #    $SKIMDIR/Patterns/Author/Kill
  197. #        A directory with one file per newsgroup, and optionally m4 include 
  198. #        files. The files contain regular expressions which are used to 
  199. #        automatically kill authors when 'skim subjects' is performed.
  200. #    $SKIMDIR/Killed
  201. #        A directory with one file per news group. The files contain the 
  202. #        subjects which were automatically killed by skim. Use 'skim cleanup' 
  203. #        regularly to remove these files.
  204. #    $SKIMDIR/Post
  205. #        This is where 'skim replyto' and 'skim newarticle' put the messages
  206. #        they have constructed. 'skim postall' posts all articles it finds in
  207. #        this directory.
  208. #    $SKIMDIR/Posted
  209. #        'skim posts' moves all messages it has posted successfully to this
  210. #        directory. Skim never removes articles from this directory.
  211. #    $SKIMDIR/Indexes/Articles
  212. #        This is where skim stores article index files. The name of an article
  213. #        index file is the name of it's newsgroup. The format is one article 
  214. #        per line. Every line consists of the article number, a space and the 
  215. #        subject line (which may contain spaces).
  216. # COPYRIGHT
  217. #    Skim - Off-line news reading package optimized for slow lines.
  218. #    Copyright (C) 1996  Rene W.J. Pijlman
  219. #
  220. #    This program is free software; you can redistribute it and/or modify
  221. #    it under the terms of the GNU General Public License as published by
  222. #    the Free Software Foundation; either version 2 of the License, or
  223. #    (at your option) any later version.
  224. #
  225. #    This program is distributed in the hope that it will be useful,
  226. #    but WITHOUT ANY WARRANTY; without even the implied warranty of
  227. #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  228. #    GNU General Public License for more details.
  229. #
  230. #    You should have received a copy of the GNU General Public License
  231. #    along with this program; if not, write to the Free Software
  232. #    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  233. # VERSION
  234. #    Skim version 0.8.4.
  235. #    $Header: /home/rene/sys/CVS_MasterSourceRepository/skim/skim,v 1.9 1996/02/17 22:47:36 rene Exp $
  236.  
  237. allow_null_glob_expansion=True
  238.  
  239. USAGE=\
  240. "Usage: skim subjects\n\
  241.        skim articles\n\
  242.        skim cleanup\n\
  243.        skim newarticle [FileName NewsGroups Subject] \n\
  244.        skim replyto ArticleFile ...\n\
  245.        skim post ArticleFile\n\
  246.        skim postall\n\
  247.        skim newsgroups\n\
  248.        skim delete ArticleFile\n\
  249.        skim keep ArticleFile\n\
  250.        skim indexes\n\
  251.        skim version\n\
  252.        skim listsubscribednewsgroups\n\
  253. "
  254.  
  255. # A SPACE and a TAB.
  256. Blank="     "
  257.  
  258. ListSubscribedNewsGroups() {
  259.     # Filter out comment lines.
  260.     grep '^[^#]' $SKIMDIR/Admin/SubscribedNewsGroups
  261. }
  262.  
  263. NewArticle() {
  264.     if [ $# -eq 0 ]
  265.     then
  266.     REPLY=""
  267.     while [ "$REPLY" = "" -o -f "$SKIMDIR/Post/$REPLY" ]
  268.     do
  269.         if [ -f "$SKIMDIR/Post/$REPLY" ]
  270.         then
  271.         echo "File $SKIMDIR/Post/$REPLY already exists" 1>&2
  272.         fi
  273.  
  274.         echo "Enter the local file name for the article file:"
  275.         read
  276.     done
  277.     Article=$REPLY
  278.  
  279.     REPLY=""
  280.     while [ "$REPLY" = "" ]
  281.     do
  282.         echo "Enter a comma-separated list of newsgroups (use '\' for line continuation):"
  283.         read
  284.     done
  285.     NewsGroups="$REPLY"
  286.  
  287.     REPLY=""
  288.     while [ "$REPLY" = "" ]
  289.     do
  290.         echo "Enter the subject:"
  291.         read
  292.     done
  293.     Subject="$REPLY"
  294.     elif [ $# -eq 3 ]
  295.     then
  296.     if [ "$1" != "" ]
  297.     then
  298.         Article="$1"
  299.     else
  300.         echo "No filename" 1>&2 
  301.         exit 1
  302.     fi
  303.  
  304.     NewsGroups="$2"
  305.     if [ "$NewsGroups" = "" ]
  306.     then
  307.         echo "No newsgroup" 1>&2 
  308.         exit 1
  309.     fi
  310.  
  311.     Subject="$3"
  312.     if [ "$Subject" = "" ]
  313.     then
  314.         echo "No subject" 1>&2 
  315.         exit 1
  316.     fi
  317.     else
  318.     echo "Usage: NewArticle [FileName NewsGroups Subject]" 1>&2
  319.     exit 1
  320.     fi
  321.  
  322.     ConstructArticle new "$Article" "$NewsGroups" "$Subject"
  323.     if [ "$?" -ne 0 ]
  324.     then
  325.     echo "Cannot create article" 1>&2
  326.     exit 1
  327.     fi
  328. }
  329.  
  330. export IAmSkim="1"
  331.  
  332. if [ $# -lt 1 ]
  333. then
  334.     echo -e "$USAGE" 1>&2
  335.     exit 1
  336. fi
  337.  
  338. if [ "$NNTPSERVER" = "" ]
  339. then
  340.     (
  341.     echo
  342.     echo "Error: environment variable NNTPSERVER is not set"
  343.     echo
  344.     echo "Skim needs to know the hostname of your news server. Please ask"
  345.     echo "your news administrator or ISP. Set the name in the environment"
  346.     echo "variable NNTPSERVER. For example, when you use bash(1) or another"
  347.     echo "sh(1) compatible shell, put in your .profile:"
  348.     echo
  349.     echo "  NNTPSERVER=news.myisp.com; export NNTPSERVER"
  350.     echo
  351.     echo "Then logout and login again to initialize your shell and window"
  352.     echo "manager with the changes in .profile."
  353.     echo
  354.     ) 1>&2
  355.  
  356.     exit 1
  357. fi
  358.  
  359. if [ "$SKIMFROM" = "" ]
  360. then
  361.     (
  362.     echo
  363.     echo "Error: environment variable SKIMFROM is not set"
  364.     echo
  365.     echo "Skim needs to know your name and email address when it constructs a"
  366.     echo "news article. Set your name and address in the proper format in the"
  367.     echo "environment variable SKIMFROM. For example, when you use bash(1)"
  368.     echo "or another sh(1) compatible shell, put a line like this in your"
  369.     echo ".profile:"
  370.     echo
  371.     echo "  SKIMFROM=\"R.W.Pijlman@inter.NL.net (Rene Pijlman)\"; export SKIMFROM"
  372.     echo
  373.     echo "Then logout and login again to initialize your shell and window"
  374.     echo "manager with the changes in .profile."
  375.     echo
  376.     ) 1>&2
  377.  
  378.     exit 1
  379. fi
  380.  
  381. # Use default value for $SKIMDIR when not set.
  382. if [ "$SKIMDIR" = "" ]
  383. then
  384.     export SKIMDIR=~/Skim
  385. fi
  386.  
  387. export SkimTmp=${TMPDIR:-/tmp}
  388.  
  389. SkimProcesses=${SKIMPROCESSES:-4}
  390. if [ "$SkimProcesses" -lt 1 ]
  391. then
  392.     echo "Invalid value for \$SKIMPROCESSES: $SKIMPROCESSES" 1>&2
  393.     exit 1
  394. fi
  395.  
  396. SkimDirectories="$SKIMDIR \
  397.                  $SKIMDIR/Admin \
  398.                  $SKIMDIR/Subjects \
  399.                  $SKIMDIR/Skipped \
  400.                  $SKIMDIR/Deleted \
  401.                  $SKIMDIR/Kept \
  402.                  $SKIMDIR/Articles \
  403.                  $SKIMDIR/Indexes \
  404.                  $SKIMDIR/Indexes/Articles \
  405.                  $SKIMDIR/CurrentArticleNumber \
  406.                  $SKIMDIR/Post \
  407.                  $SKIMDIR/Posted"
  408.  
  409. if [ "$SKIMAUTOSUBJECT" = "CaseSensitive" -o \
  410.      "$SKIMAUTOSUBJECT" = "CaseInsensitive" ]
  411. then
  412.     SkimDirectories="$SkimDirectories \
  413.                      $SKIMDIR/Patterns \
  414.                      $SKIMDIR/Patterns/Subject \
  415.                      $SKIMDIR/Patterns/Subject/AutoSelect \
  416.                      $SKIMDIR/Patterns/Subject/Kill \
  417.                      $SKIMDIR/Killed"
  418. elif [ "$SKIMAUTOSUBJECT" != "" ]
  419. then
  420.     echo "Invalid value in \$SKIMAUTOSUBJECT: $SKIMAUTOSUBJECT" 1>&2
  421.     exit 1
  422. fi
  423.  
  424. if [ "$SKIMAUTOAUTHOR" = "CaseSensitive" -o \
  425.      "$SKIMAUTOAUTHOR" = "CaseInsensitive" ]
  426. then
  427.     SkimDirectories="$SkimDirectories \
  428.                      $SKIMDIR/Patterns \
  429.                      $SKIMDIR/Patterns/Author \
  430.                      $SKIMDIR/Patterns/Author/AutoSelect \
  431.                      $SKIMDIR/Patterns/Author/Kill \
  432.                      $SKIMDIR/Killed"
  433. elif [ "$SKIMAUTOAUTHOR" != "" ]
  434. then
  435.     echo "Invalid value in \$SKIMAUTOAUTHOR: $SKIMAUTOAUTHOR" 1>&2
  436.     exit 1
  437. fi
  438.  
  439. # Create missing parts of directory structure.
  440. for Directory in $SkimDirectories
  441. do
  442.     if [ ! -d $Directory ]
  443.     then
  444.     mkdir $Directory
  445.     if [ $? -ne 0 ]
  446.     then
  447.         echo "Cannot create directory $Directory" 1>&2
  448.         exit 1
  449.     fi
  450.     fi
  451. done
  452.  
  453. # Create default SubscribedNewsGroups if necessary.
  454. if [ ! -f $SKIMDIR/Admin/SubscribedNewsGroups ]
  455. then
  456.     echo "# These are the default news groups you are subscribed to." \
  457.           >> $SKIMDIR/Admin/SubscribedNewsGroups
  458.     echo "news.announce.newusers" >> $SKIMDIR/Admin/SubscribedNewsGroups
  459.     echo "news.newusers.questions" >> $SKIMDIR/Admin/SubscribedNewsGroups
  460.     echo "comp.os.linux.advocacy" >> $SKIMDIR/Admin/SubscribedNewsGroups
  461. fi
  462.  
  463. if [ "$SKIMAUTOSUBJECT" != "" ]
  464. then
  465.     # Create default pattern file if necessary.
  466.     for Group in `ListSubscribedNewsGroups`
  467.     do
  468.     if [ ! -f $SKIMDIR/Patterns/Subject/Kill/$Group ]
  469.     then
  470.         echo "include(AllGroups)" >$SKIMDIR/Patterns/Subject/Kill/$Group
  471.     fi
  472.  
  473.     if [ ! -f $SKIMDIR/Patterns/Subject/AutoSelect/$Group ]
  474.     then
  475.         echo "include(AllGroups)" \
  476.             >$SKIMDIR/Patterns/Subject/AutoSelect/$Group
  477.     fi
  478.     done
  479.  
  480.     if [ ! -f $SKIMDIR/Patterns/Subject/Kill/AllGroups ]
  481.     then
  482.     touch $SKIMDIR/Patterns/Subject/Kill/AllGroups
  483.     fi
  484.  
  485.     if [ ! -f $SKIMDIR/Patterns/Subject/AutoSelect/AllGroups ]
  486.     then
  487.     touch $SKIMDIR/Patterns/Subject/AutoSelect/AllGroups
  488.     fi
  489. fi
  490.  
  491. if [ "$SKIMAUTOAUTHOR" != "" ]
  492. then 
  493.     # Create default pattern file if necessary.
  494.     for Group in `ListSubscribedNewsGroups`
  495.     do
  496.     if [ ! -f $SKIMDIR/Patterns/Author/Kill/$Group ]
  497.     then
  498.         echo "include(AllGroups)" >$SKIMDIR/Patterns/Author/Kill/$Group
  499.     fi
  500.  
  501.     if [ ! -f $SKIMDIR/Patterns/Author/AutoSelect/$Group ]
  502.     then
  503.         echo "include(AllGroups)" \
  504.             >$SKIMDIR/Patterns/Author/AutoSelect/$Group
  505.     fi
  506.     done
  507.  
  508.     if [ ! -f $SKIMDIR/Patterns/Author/Kill/AllGroups ]
  509.     then
  510.     touch $SKIMDIR/Patterns/Author/Kill/AllGroups
  511.     fi
  512.  
  513.     if [ ! -f $SKIMDIR/Patterns/Author/AutoSelect/AllGroups ]
  514.     then
  515.     touch $SKIMDIR/Patterns/Author/AutoSelect/AllGroups
  516.     fi
  517. fi
  518.  
  519. if [ "$1" = "subjects" ]
  520. then
  521.     if [ $# -gt 1 ]
  522.     then
  523.     echo -e "$USAGE" 1>&2 
  524.     exit 1
  525.     fi
  526.  
  527.     Dispatch GetSubjectsOfNewArticlesInGroup `ListSubscribedNewsGroups`
  528.  
  529. elif [ "$1" = "articles" ]
  530. then
  531.     if [ $# -gt 1 ]
  532.     then
  533.     echo -e "$USAGE" 1>&2 
  534.     exit 1
  535.     fi
  536.  
  537.     Dispatch GetSelectedArticlesInGroup `ListSubscribedNewsGroups`
  538.  
  539. elif [ "$1" = "cleanup" ]
  540. then
  541.     if [ $# -gt 1 ]
  542.     then
  543.     echo -e "$USAGE" 1>&2 
  544.     exit 1 
  545.     fi
  546.  
  547.     rm -f $SKIMDIR/Skipped/* \
  548.           $SKIMDIR/Killed/* \
  549.           $SKIMDIR/Deleted/*
  550.  
  551. elif [ "$1" = "replyto" ]
  552. then
  553.     if [ $# -lt 2 ]
  554.     then
  555.     echo -e "$USAGE" 1>&2
  556.     exit 1
  557.     fi
  558.     shift 1
  559.     ConstructArticle reply $*
  560. elif [ "$1" = "newarticle" ]
  561. then
  562.     if [ $# -eq 1 ]
  563.     then
  564.         NewArticle
  565.     elif [ $# -eq 4 ]
  566.     then
  567.     ConstructArticle new "$2" "$3" "$4"
  568.     else
  569.     echo -e "$USAGE" 1>&2
  570.     exit 1
  571.     fi
  572. elif [ "$1" = "postall" ]
  573. then
  574.     if [ $# -ne 1 ]
  575.     then
  576.     echo -e "$USAGE" 1>&2
  577.     exit 1
  578.     fi
  579.     (
  580.     cd $SKIMDIR/Post
  581.     PostArticle *
  582.     )
  583. elif [ "$1" = "post" ]
  584. then
  585.     if [ $# -ne 2 ]
  586.     then
  587.     echo -e "$USAGE" 1>&2
  588.     exit 1
  589.     fi
  590.     PostArticle "$2"
  591. elif [ "$1" = "newsgroups" ]
  592. then
  593.     if [ $# -ne 1 ]
  594.     then
  595.     echo -e "$USAGE" 1>&2
  596.     exit 1
  597.     fi
  598.  
  599.     if [ -f $SKIMDIR/Admin/AllNewsGroups ]
  600.     then
  601.     mv $SKIMDIR/Admin/AllNewsGroups $SKIMDIR/Admin/AllNewsGroups.previous
  602.     fi
  603.  
  604.     # The sed removes the information that comes after the name of the
  605.     # newsgroup.
  606.     GetListOfGroups | sed "s/[$Blank].*//" | \
  607.         sort -o $SKIMDIR/Admin/AllNewsGroups
  608.  
  609.     if [ -f $SKIMDIR/Admin/AllNewsGroups.previous ]
  610.     then
  611.     diff $SKIMDIR/Admin/AllNewsGroups.previous \
  612.          $SKIMDIR/Admin/AllNewsGroups >$SKIMDIR/Admin/AllNewsGroups.diff
  613.     fi
  614. elif [ "$1" = "indexes" ]
  615. then
  616.     if [ $# -ne 1 ]
  617.     then
  618.     echo -e "$USAGE" 1>&2
  619.     exit 1
  620.     fi
  621.  
  622.     rm -f $SKIMDIR/Indexes/Articles/*
  623.  
  624.     RebuildArticleIndexes
  625.  
  626. elif [ $1 = "delete" -o $1 = "keep" ]
  627. then
  628.     if [ $# != 2 ]
  629.     then
  630.     echo -e "$USAGE" 1>&2
  631.     exit 1
  632.     fi
  633.  
  634.     if [ $1 = "delete" ]
  635.     then
  636.         mv $SKIMDIR/Articles/$2 $SKIMDIR/Deleted
  637.     elif [ $1 = "keep" ]
  638.     then
  639.         mv $SKIMDIR/Articles/$2 $SKIMDIR/Kept
  640.     else
  641.         echo "Can't happen" 1>&2
  642.         exit 1
  643.     fi
  644.  
  645.     # Remove the article from the index files.
  646.     TmpIndex=${SkimTmp}/articleindex.$$
  647.  
  648.     Group=`echo $2 | sed -e 's/\.[0-9]*$//'`
  649.     ArticleNumber=`echo $2 | sed -e 's/^.*\.//'`
  650.  
  651.     mv -f $SKIMDIR/Indexes/Articles/$Group $TmpIndex
  652.     grep -v "^$ArticleNumber" $TmpIndex >$SKIMDIR/Indexes/Articles/$Group
  653.  
  654.     rm -f $TmpIndex
  655.  
  656.     # Remove if empty.
  657.     if [ ! -s $SKIMDIR/Indexes/Articles/$Group ]
  658.     then
  659.     rm -f $SKIMDIR/Indexes/Articles/$Group
  660.     fi
  661. elif [ "$1" = "version" ]
  662. then
  663.     if [ $# -ne 1 ]
  664.     then
  665.     echo -e "$USAGE" 1>&2
  666.     exit 1
  667.     fi
  668.     echo "skim version 0.8.4"
  669. elif [ "$1" = "listsubscribednewsgroups" ]
  670. then
  671.     ListSubscribedNewsGroups
  672. else
  673.     echo -e "$USAGE" 1>&2
  674.     exit 1
  675. fi
  676.  
  677. wait
  678.  
  679. exit 0
  680.